<script>
import api from '@/api/index'

export default {
  name: "index",
  data() {
    return {
      total: 0,
      tableData: [],
      queryParam: {
        pageSize: 2,
        pageNum: 1
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      let data = await api.gong_kai_zhi_du(this.queryParam);

      this.tableData = data.records;
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>

<template>
  <div>
    <el-row class="bg-white py-3">
      <el-col :span="24">
        <div class="px-3 py-2 text-white bg-[#2d66a5] inline-block">政府信息公开制度</div>
      </el-col>
      <el-col :span="24">
        <el-table
            :show-header="false"
            :data="tableData"
            style="width: 100%">

          <el-table-column>
            <template #default="{row}">
              <router-link :to="`/gong_kai_zhi_du/detail?id=${row.id}`">
                <div class="flex justify-between items-center py-2">
                  <div>{{ row.title }}</div>
                  <div>{{ row.createdTime }}</div>
                </div>
              </router-link>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="24" class="mt-2 flex justify-center">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryParam.pageNum"
            :page-sizes="[5,10,20]"
            :page-size="queryParam.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>

</style>
